package lumis.portal.presentation.perspective;

import lumis.portal.presentation.core.HTMLFragmentComponent;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;

/**
 * Fragment to generate the SubHeader.
 *
 * @version $Revision: 13214 $ $Date: 2011-07-07 21:46:10 -0300 (Thu, 07 Jul 2011) $
 * @since 6.0.0
 */
public abstract class AbstractSubHeader extends HTMLFragmentComponent
{
	/**
	 * @since 6.0.0
	 */
	private static final long serialVersionUID = -4155219615450018691L;
	
	/**
	 * @since 6.0.1
	 */
	private boolean hidden;

	public AbstractSubHeader(String id, boolean hidden)
	{
		super(id);
		this.hidden = hidden;
	}
	
	/**
	 * Sets the Sub Bar to be hidden.
	 * @param hide true if to be hidden, false if not.
	 * @since 6.0.1
	 */
	protected void setHidden(boolean hide){
		this.hidden = hide;
	}
	
	/**
	 * Verifies if the Sub Bar is set to be hidden.
	 * @return the bar status.
	 * @since 6.0.1
	 */
	protected boolean isHidden(){
		return this.hidden;
	}
	
	@Override
	protected CharSequence getHTMLFragment(MarkupStream markupStream, ComponentTag openTag)
	{
		String style = "style=\"border-bottom:1px solid #999; !important;" +(hidden?" display:none;":"display:block;") + "\"";
		return "<div id=\"lumSubBarOuter\"><div id=\"lumSubBar\" class=\"sub\" "+ style +"\">" + getContent() + "</div></div>";
	}
	
	protected abstract String getContent();

}
